<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'/ukkepuk/source/php/classes/beans/Family.php'); 
	require_once($_SERVER['DOCUMENT_ROOT'].'/ukkepuk/source/php/classes/beans/Communication.php'); 
	
	
	class depricated_Kid{
		var $name = "name";
		var $firstname = "firstname";
		var $profileImage = "";
		
		var $street;
		var $number;
		var $postal;
		var $city;
		
		var $id = -1;
		var $addressId = -1;

		var $family = Array();
		var $communication = Array();
		
        //TOD: split time into other object
        var $startTime;
        var $endTime;
		
		
		public function addFamily($familymember){
			array_push($this->family, $familymember);
		}
		
		public function addCommunication($comm){
			array_push($this->communication, $comm);
		}
		
		public function addCommunicationTypeOnPos($type, $index){
			
			if(array_key_exists($index, $this->communication)){
				$com =$this->communication[$index];
				$com->type = $type;
			}else {
				$com = new Communication();
				$com->type = $type;
				$this->communication[$index] = $com;
			}
		}
		
		public function addCommunicationValueOnPos($val, $index){
			
			if(array_key_exists($index, $this->communication)){
				$com =$this->communication[$index];
				$com->value = $val;
			}else {
				$com = new Communication();
				$com->value = $val;
				$this->communication[$index] = $com;
			}
		}
		
		public function addCommunicationTypeForFamilyOnPos($type, $famIndex, $commIndex){
			if(array_key_exists($famIndex, $this->family)){
				if(array_key_exists($commIndex, $this->family[$famIndex]->communication)){
					$com = $this->family[$famIndex]->communication[$commIndex];
					$com->type = $type;
				}
				else {
					$com = new Communication();
					$com->type = $type;
					$this->family[$famIndex]->communication[$commIndex] = $com;
				}
			}else {
				$fam = new Family();
				$com = new Communication();
				$com->type = $type;
				$fam->communication[$comIndex] = $com;
				$this->family[$famIndex] = $fam;
				
			}
		}
		
		public function addCommunicationValueForFamilyOnPos($value, $famIndex, $commIndex){
			if(array_key_exists($famIndex, $this->family)){
				if(array_key_exists($commIndex, $this->family[$famIndex]->communication)){
					$com = $this->family[$famIndex]->communication[$commIndex];
					$com->value = $value;
				}
				else {
					$com = new Communication();
					$com->value = $value;
					$this->family[$famIndex]->communication[$commIndex] = $com;
				}
			}else {
				$fam = new Family();
				$com = new Communication();
				$com->value = $value;
				$fam->communication[$comIndex] = $com;
				$this->family[$famIndex] = $fam;
				
			}
		}

		
		public function addFamilyTypeOnPos ($val, $index){
			echo "add fam $val on pos $index <br/>";
			if(array_key_exists($index, $this->family)){
				$fam =$this->family[$index];
				$fam->type = $val;
			}else {
				$fam = new Family();
				$fam->type = $val;
				$this->family[$index] = $fam;
			}
			
		}

		public function addFamilyNameOnPos ($val, $index){
			if(array_key_exists($index, $this->family)){
				$fam =$this->family[$index];
				$fam->name = $val;
			}else {
				$fam = new Family();
				$fam->name = $val;
				$this->family[$index] = $fam;
			}
		}

		public function addFamilyFirstNameOnPos ($val, $index){
			if(array_key_exists($index, $this->family)){
				$fam =$this->family[$index];
				$fam->firstname = $val;
			}else {
				$fam = new Family();
				$fam->firstname = $val;
				$this->family[$index] = $fam;
			}
		}
		
		
		
		public function toString() {
			echo "<br/><hr/>name: " . $this->name . " and " . $this->firstname . "<br/>";
			echo "communication: <br/>";
			foreach($this->communication as $com){
				$com->toString();
			}
			
			echo "family: <br/>";
			foreach($this->family as $fam){
				$fam->toString();
			}
			
			
			echo "<hr/>";
		}
        
        public function toXml(){
            return "<kid name=\"".$this->name."\" firstname=\"".$this->firstname."\" />";
        }
		
	}

?>